#pragma once

#include <widgets/SCalendar.h>
#include <widgets/table/STable.h>

#include <QDesktopWidget>
#include <QItemDelegate>
#include <QModelIndex>
#include <QPainter>
#include <QStyledItemDelegate>
#include <QWidget>
#include <map>

#include "QbBondDefines.h"

enum { holidayNull = 0, holidayCib, holidaySSE };
enum calendarShowType {
  TopCursor = 0,
  BottomCursor,
  TopOrBottomCursor  // 超过屏幕则向上，否则向下
};
class SCalendar;
class QDesktopWidget;
class STableColumnSet;
class S_QBBOND_EXPORT RemainDateDelegate : public DefaulTableItemDelegate {
  Q_OBJECT
 public:
  RemainDateDelegate(QObject* parent, STableColumnSet* colSet,
                     calendarShowType showType);
  void paint(QPainter* painter, const QStyleOptionViewItem& option,
             const QModelIndex& index) const;
  QSize sizeHint(const QStyleOptionViewItem& option,
                 const QModelIndex& index) const;
  bool eventFilter(QObject* object, QEvent* event);
 protected slots:
  void onClearHolidayRect();

 private:
  mutable std::map<QString, QRect> m_holidayRectMap;
  SVirtualTable* m_table;
  QScopedPointer<SCalendar> m_tipCalendar;
  calendarShowType m_showType;
};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

class S_QBBOND_EXPORT BrokerCorpDelegate : public DefaulTableItemDelegate {
  Q_OBJECT
 public:
  BrokerCorpDelegate(QObject* parent);
  void paint(QPainter* painter, const QStyleOptionViewItem& option,
             const QModelIndex& index) const;
  QSize sizeHint(const QStyleOptionViewItem& option,
                 const QModelIndex& index) const;
};

class ExchangeSeqNoDelegate : public DefaulTableItemDelegate {
  Q_OBJECT
 public:
  ExchangeSeqNoDelegate(QObject* parent) : DefaulTableItemDelegate(parent) {}
  void paint(QPainter* painter, const QStyleOptionViewItem& option,
             const QModelIndex& index) const override;
};
